package com.example;

import com.example.mapper_practice.MapperImportBD;
import com.example.mapper_practice.MapperInterface;
import com.example.post_process.User;
import com.example.service.H;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

@SpringBootApplication
@Import(MapperImportBD.class)
public class BootQrCodeApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(BootQrCodeApplication.class, args);
        H h = run.getBean("h", H.class);
        System.out.println(h);

        System.out.println(h.getA());
        System.out.println("-----------------");

        Object bean = run.getBean("myFactoryBean");
        System.out.println(bean);

        System.out.println("-----------------");


        System.out.println(run.getBean(MapperInterface.class.getSimpleName()));

        System.out.println("-------- practice beanFactoryPostProcessor---------");
        User user1 = run.getBean("getUser", User.class);
        System.out.println(user1.getAge());


        System.out.println("********************************");

        User bean1 = run.getBean(User.class);
        System.out.println(bean1);
    }

    @Bean
    public User getUser() {
        return new User();
    }

}
